<?php
// +---------------------------------------------------------------------+
// | ALINEJUN    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/ALINEJUN                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 文化控制器
 */
class Culture extends AdminBase
{
    
    /**
     * 文化列表
     */
    public function cultureList()
    {
        
        $where = $this->logicCulture->getWhere($this->param);
        
        $this->assign('list', $this->logicCulture->getCultureList($where, '*', 'create_time desc'));
        
        return $this->fetch('culture_list');
    }

    /**
     * 获取城市Select结构数据
     */
    public function getCitySelectData()
    {

        $city_select = $this->logicCity->cityToSelect($this->cityListTree);

        $this->assign('city_select', $city_select);
    }
    /**
     * 文化添加
     */
    public function cultureAdd()
    {
        
        $this->cultureCommon();
        $this->getCitySelectData();
        return $this->fetch('culture_edit');
    }
    
    /**
     * 文化编辑
     */
    public function cultureEdit()
    {
        
        $this->cultureCommon();
        
        $info = $this->logicCulture->getCultureInfo(['id' => $this->param['id']], '*');
        
        !empty($info) && $info['img_ids_array'] = str2arr($info['img_ids']);
        $this->getCitySelectData();
        $this->assign('info', $info);
        
        return $this->fetch('culture_edit');
    }
    
    /**
     * 文化添加与编辑通用方法
     */
    public function cultureCommon()
    {
        
        IS_POST && $this->jump($this->logicCulture->cultureEdit($this->param));
        
        //$this->assign('culture_category_list', $this->logicCulture->getCultureCategoryList([], 'id,name', '', false));
    }
    /**
     * 文化分类删除
     */
    public function cultureCategoryDel($id = 0)
    {
        
        $this->jump($this->logicCulture->cultureCategoryDel(['id' => $id]));
    }
    
    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('Culture', $this->param));
    }
}
